package main

import (
	"fmt"
	"os"
	"path"

	log "github.com/Sirupsen/logrus"
	flag "github.com/ogier/pflag"

	"github.com/spf13/viper"
)

func main() {
	loadConfigFile()
}

func loadConfigFile() {
	// parse command line
	configPath := flag.StringP("config", "c", "./config/dev.json", "configuration file path")
	flag.Parse()

	file, err := os.Open(*configPath)
	defer file.Close()
	if err != nil {
		log.Fatalln(err)
	}
	extName := path.Ext(*configPath)[1:]
	viper.SetConfigType(extName)
	viper.ReadConfig(file)
	gName := viper.GetString("name.ga")
	fmt.Println(gName)
	gInt := viper.GetInt("name.miao")
	fmt.Println(gInt)
}
